<template>
  <div class="auto">
    <validator name='v'>
      <form class="form-horizontal">
        <!-- <ul class="nav nav-tabs">
          <li role="presentation" class="active"><a href="#">停用信息</a></li>
        </ul> -->
        <p class="bg-info text-center" style="padding: 8px;">停用信息</p>
        <div class="row" style="margin-top:10px;">
          <div class="form-group" :class="[$v.f_reason.required ? 'has-error' : 'has-success']">
            <label for="f_reason" class=" col-sm-2 control-label">停用原因:</label>
            <div class="col-sm-2 " :class="[!$refs.reason.selectedItems || $refs.reason.selectedItems === '' ? 'select-error' : '']">
              <input type="text" v-show="false" v-model="$refs.reason.selectedItems" v-validate="['required']" :field="'reason' + $index">
              <v-select id="f_reason"
              v-model="model.f_reason"
              placeholder='停用原因'
              :value.sync="model.f_reason"
              :options='reason'
              v-ref:reason
              close-on-select ></v-select>
            </div>
          </div>
        </div>
        <div class="row" style="margin-top:1px;" v-if= "model.f_reason[0] === '其他'">
          <div class="col-sm-8 col-sm-offset-2">
            <textarea class="form-control" v-model="model.f_othereason"  rows="3" placeholder="请填写原因"></textarea>
          </div>
        </div>
      </form>
      <div style="text-align:right;height:auto;margin-top:30px;margin-right:50px;">
        <button class="btn btn-success" @click="confirm()"  :disabled='!$v.valid'>确&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;认</button>
        <button class="btn btn-default" @click="clean()" style="width:80px;margin-left:20px;">取&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;消</button>
      </div>
    </validator>
  </div>
</template>
<script>
/**
*综合业务
表具停用组件
*/
import AppData from '../../../../../stores/AppData'
export default {
  title: '表具停用',
  props: ['row'],
  data () {
    return {
      model: {}
    }
  },
  methods: {
    confirm () {
      this.$LogicService.meterDisable(this.model, this.row)
      .then(
        (res) => {
          this.$dispatch('success', '表具停用', this.row, res)
        }
      ).catch(
        (error) => {
          if (error.state === 603) {
            this.$error('重复提交')
            return
          }
          this.$dispatch('error', '表具停用', this.row, error)
        }
      )
    },
    clean () {
      this.$info('取消操作')
      this.$dispatch('clean', '表具停用', this.row)
    }
  },
  computed: {
    reason () {
      return AppData.getParam('停用原因')
    }
  }
}
</script>

<style>
</style>
